#pragma once

#include<stdio.h>
#include<malloc.h>
#include<assert.h>

//顶点默认元素个数
#define Default_Vertex_Size 20
#define T  char //顶点元素类型
//边结构
typedef struct Edge
{
	int dest;  //存放顶点下标
	struct Edge* link;//连接下一个顶点
}Edge;
//顶点结构
typedef struct Vertex
{
	T data;//顶点数据
	Edge* adj;//指向边结构指针
}Vertex;
//邻接表
typedef struct GraphLnk
{
	int MaxVertices; //最大顶点个数
	int NumVertices; //实际顶点个数
	int NumEdges;  //边的条数

	Vertex* NodeTable; //指向顶点结构表
}GraphLnk;

void InitGraph(GraphLnk* g);
int  GetVertexPos(GraphLnk* g, T v);
void ShowGraph(GraphLnk* g);
void InsertVertex(GraphLnk* g, T v);
void InsertEdge(GraphLnk* g, T vertex1, T vertex2);

void RemoveEdge(GraphLnk* g, T vertex1, T vertex2);
void RemoveVertex(GraphLnk* g, T vertex);
void DestroyGraph(GraphLnk* g);
int  GetFirstNeighbor(GraphLnk* g, T vertex);
int  GetNextNeighbor(GraphLnk* g, T vertex1, T vertex2);
T    GetVertexValue(GraphLnk* g, int v);

////////////////////////////////////////////////////////////
//
void DFS(GraphLnk* g, T vertex);
void DFS(GraphLnk* g, int v, bool visited[]);
void BFS(GraphLnk* g, T vertex);
void BFS(GraphLnk* g, int v, bool visited[]);
void NonUnicomDFS(GraphLnk* g);
void NonUnicomBFS(GraphLnk* g);